﻿using System.Windows;

namespace CSharpAllDemo.Serial
{
    /// <summary>
    /// SerialPortWindow.xaml 的交互逻辑
    /// </summary>
    public partial class SerialPortWindow : Window
    {
        public SerialPortWindow()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            SerialPortManager.Instance.Open("COM3", 9600, (byte[] messageByte) =>
            {

            });
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            SerialPortManager.Instance.Write([1, 2, 3, 4, 5, 6]);
        }

        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            SerialPortManager.Instance.WriteCallBack([1, 2, 3, 4, 5, 6],
                (bool isSuccess, byte[] messageByte) =>
            {
                if (isSuccess)
                {
                    MessageBox.Show("响应成功");
                }
                else
                {
                    MessageBox.Show("响应失败");
                }
            }, 5000);

        }

        private void Button_Click_3(object sender, RoutedEventArgs e)
        {

        }
    }
}
